Con log:"Init" from:"Vector".
Repl newClass:"VectorClass".
VectorClass setParent:XClass.
(VectorClass new) setName:"Vector".
Vector addField:"array".
Vector addField:"used".

Repl methodIn:Vector.
initialize[
    array <- Array new: 10.
    used <- 0.
]
Repl methodIn:Vector.
clear [
    (Range from:0 to: used) do: [i:||
        array at:i set:null.
    ].
    used <- 0.
]

Repl methodIn:Vector.
add: e[
    self checkSize: (used+1).
    array at: used set:e.
    used <- (used+1).
]

Repl methodIn:Vector.
checkSize: size[
    ((array length) > size)
        ifTrue:[||self]
        else:[|| array <- (array resize: (size + 10)) ]
]
Repl methodIn:Vector.
toString [
   ^ ((self length)>0) ifTrue:[||
       x <- StringBuffer new.
       x append: "Vector(".
       (Range from:0 to: ((self length)-1)) do: [i:||
          x append: ((self at:i) toString).
          x append: ",".
       ].
       x append: ((self at: ((self length)-1)) toString).
       x append: ")".
       ^x toString.
    ] else:
    [|| ^ "Vector()"].
]

Repl methodIn:Vector.
length[
    ^used.
]
Repl methodIn:Vector.
at:i[
    ^array at:i.
]
Repl methodIn:Vector.
at:i set:x[
    ^array at:i set:x.
]